/**
 * Created by IntelliJ IDEA.
 * User: Alexander Fedulin
 * Date: 01.11.11
 * Time: 13:42
 * To change this template use File | Settings | File Templates.
 */

import java.awt.*;
import java.awt.geom.Point2D;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class Average {

    private String problem_input = "average.in";
    private String problem_output = "average.out";
    private BufferedReader br;
    private StringTokenizer st;
    private PrintWriter out;

    String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
    private int n, k;
    private double a[] = new double[2000];
    public class Pair implements Comparable<Pair>
    {
        double f;
        int s;
        Pair()
        {
            f = s = 0;
        }
        Pair (double f, int s)
        {
            this.f = f;
            this.s = s;
        }
        public int compareTo(Pair o)
        {
            if (f < o.f - 1e-9) return -1;
            if (f > o.f + 1e-9) return 1;
            return s - o.s;
        }
    }

    void load() throws IOException {
        n = nextInt();
        k = nextInt();
        for (int i = 0; i < n; i++)
        {
            a[i] = nextInt();
        }
        Arrays.fill(was, 0, 2 * n, false);
    }
    boolean was[] = new boolean[2010];
    ArrayList <Point> op = new ArrayList<Point>();
    double test[] = new double[1000];
    boolean can(int i)
    {
        int sz = 0;
        for (int j = 0; j < n + i; j++)
        {
            if (was[j]) continue;
            test[sz++] = a[j];
        }
        for (int j = i; j < n - 1; j++)
        {
            Arrays.sort(test, 0, sz);
            test[sz - 2] = (test[sz - 2] + test[sz - 1]) * 0.5;
            sz--;
        }
        if (test[0] > k) return true;
        return false;
    }
    boolean go(int i) throws Exception
    {

        if (i == n - 1)
        {
            for (int j= 0; j < op.size(); j++)
                out.println((op.get(j).x + 1) + " " + (op.get(j).y + 1));
            return true;
        }
        if (!can(i)) return false;
        int big = -1;
        for (int k = 0; k < n + i; k++)
        {
            if (was[k]) continue;
            if (big == -1 || a[k] > a[big])
                big = k;
        }
        if (big == -1) throw new Exception("42");
        ArrayList <Pair> c = new ArrayList<Pair>();
        for (int k = 0; k < n + i; k++)
        {
            if (was[k] || k == big) continue;
            c.add(new Pair(a[k], k));
        }
        Collections.sort(c);
        for (int k = 0; k < c.size(); k++)
        {
            a[n + i] = (a[big] + c.get(k).f) * 0.5;
            op.add(new Point(big, c.get(k).s));
            was[big] = true;
            was[c.get(k).s] = true;
            if (go(i + 1)) return true;
            was[big] = false;
            was[c.get(k).s] = false;
            op.remove(new Point(big, c.get(k).s));
        }
        return false;
    }

    void MakeAverage1(ArrayList <Pair> a)
    {
        int sz = 0;
        ArrayList <Pair> all = (ArrayList<Pair>) a.clone();
        op.clear();
        while (all.size() > 5)
        {
            Collections.sort(all);
            if (all.get(0).f < k && all.get(all.size() - 1).f > k)
            {
                op.add(new Point(all.get(1).s + 1, all.get(all.size() - 2).s + 1));
                all.set(1, new Pair((all.get(1).f + (all.get(all.size() - 2).f)) * 0.5, n + sz));
                all.remove(all.size() - 2);
                sz++;
            }
            else if (all.get(all.size() - 1).f <= k)
            {
                if (all.size() > 2)
                {
                    op.add(new Point(all.get(all.size() - 2).s + 1, all.get(0).s + 1));
                    all.set(0, new Pair((all.get(all.size() - 2).f + all.get(0).f) * 0.5, n + sz));
                    all.remove(all.size() - 2);
                    sz++;
                }
                else
                {
                    op.add(new Point(all.get(1).s + 1, all.get(0).s + 1));
                    all.set(0, new Pair((all.get(1).f + all.get(0).f) * 0.5, n + sz));
                    all.remove(1);
                    sz++;
                }
            }
            else if (all.get(0).f >= k)
            {
                if (all.size() > 2)
                {
                    op.add(new Point(all.get(all.size() - 1).s + 1, all.get(1).s + 1));
                    all.set(1, new Pair((all.get(all.size() - 1).f + all.get(1).f) * 0.5, n + sz));
                    all.remove(all.size() - 1);
                    sz++;
                }
                else
                {
                    op.add(new Point(all.get(1).s + 1, all.get(0).s + 1));
                    all.set(0, new Pair((all.get(1).f + all.get(0).f) * 0.5, n + sz));
                    all.remove(1);
                    sz++;
                }
            }
        }
    }

    void solve() throws Exception
    {
            if (n == 1) return;
        ArrayList <Pair> all = new ArrayList<Pair>();
        for (int i = 0; i < n; i++)
            all.add(new Pair(a[i], i));
        Collections.sort(all);
        MakeAverage1(all);
        for (int i = 0; i < op.size(); i++)
        {
            out.println(op.get(i).x + " " + op.get(i).y);
        }
        //return;
        /*
        int fst = -1, sec = -1;
        for (int i = 0; i < n; i++)
        {
            if (all.get(i).f < k)
            {
                fst = i;
            }
            if (all.get(i).f > k)
            {
                sec = i;
                break;
            }
        }
        int sz = 0;
        for (int i = 0; i < fst; i++)
        {
            out.println((all.get(i).s + 1) + " " + (all.get(i + 1).s + 1));
            all.set(i + 1, new Pair((all.get(i).f + all.get(i + 1).f) * 0.5, n + sz));
            sz++;
        }
        if (sec != -1)
        {
            for (int i = n - 1; i > sec; i--)
            {
                out.println((all.get(i).s + 1) + " " + (all.get(i - 1).s + 1));
                all.set(i - 1, new Pair((all.get(i).f + all.get(i - 1).f) * 0.5, n + sz));
                sz++;
            }
        }
        if (fst == -1 && sec == -1)
        {
            out.println("1 2");
            sz = 1;
            for (int i = 2; i < n; i++)
            {
                out.println((i + 1) + " " + (n + sz));
                sz++;
            }
            return;
        }
        else if (fst != -1 && sec != -1)
        {
            int p, q;
            for (p = fst, q = sec; p + 1 < q;)
            {

                if (k - all.get(p).f > all.get(q).f - k)
                {
                    out.println((all.get(p).s + 1) + " " + (all.get(p + 1).s + 1));
                    all.set(p + 1, new Pair((all.get(p).f + k) * 0.5, n + sz));
                    sz++;
                    p++;
                }
                else
                {
                    out.println((all.get(q).s + 1) + " " + (all.get(q - 1).s + 1));
                    all.set(q - 1, new Pair((all.get(q).f + k) * 0.5, n + sz));
                    sz++;
                    q--;
                }
            }
            out.println((all.get(p).s + 1) + " " + (all.get(q).s + 1));
        }
        else if (fst == -1)
        {
            for (int j = sec; j > 0; j--)
            {
                    out.println((all.get(j).s + 1) + " " + (all.get(j - 1).s + 1));
                    all.set(j - 1, new Pair((all.get(j).f + k) * 0.5, n + sz));
                    sz++;
            }
        }
        else if (sec == -1)
        {
            for (int j = fst; j + 1 < n; j++)
            {
                    out.println((all.get(j).s + 1) + " " + (all.get(j + 1).s + 1));
                    all.set(j + 1, new Pair((all.get(j).f + k) * 0.5, n + sz));
                    sz++;
            }
        }
        */
    }

    void run() {
        try {
            boolean online_judge = System.getProperty("ONLINE_JUDGE") != null;
            if (online_judge) {
                br = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(new OutputStreamWriter(System.out));
            } else {
                br = new BufferedReader(new FileReader(problem_input));
                out = new PrintWriter(new FileWriter(problem_output));
            }
            int T = nextInt();
            for (int i = 0; i < T; i++)
            {
                load();
                solve();
            }
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(42);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public static void main(String args[]) {
        new Average().run();
    }
}
